package com.symaster.backups.frame.element.pagination.util;


import com.symaster.backups.frame.element.pagination.Button;
import com.symaster.backups.frame.element.pagination.ButtonType;

import java.awt.*;

/**
 * @author yinmiao
 * @version 2024/1/22
 */
public class Util {

    public static Button getRightButton(Component[] components) {
        for (Component component : components) {
            if (component instanceof Button) {
                Button button = (Button) component;
                ButtonType buttonType = button.getButtonType();
                if (buttonType == ButtonType.RIGHT_BUTTON) {
                    return button;
                }
            }
        }
        throw new NullPointerException("rightButton == null");
    }

    public static Button getLeftButton(Component[] components) {
        for (Component component : components) {
            if (component instanceof Button) {
                Button button = (Button) component;
                ButtonType buttonType = button.getButtonType();
                if (buttonType == ButtonType.LEFT_BUTTON) {
                    return button;
                }
            }
        }
        throw new NullPointerException("leftButton == null");
    }


}
